﻿package mortal.game.view.flowerSend.effect
{
    import Message.Public.*;
    import baseEngine.basic.*;
    import baseEngine.modifiers.*;
    import com.gengine.utils.pools.*;
    import flash.utils.*;
    import frEngine.render.layer.uiEffectLayer.*;
    import mortal.game.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.pools.*;
    import mortal.game.view.task.data.*;

    public class FlowerEffectImpl extends Object
    {
        private var _waveEffect:EffectPlayer;
        private var _callBack:Function;
        private var _flowerMsg:SFlowerNoticeMsg;
        private var _t:int;
        private static const redWaveEffect:String = "UI_songhua_red";
        private static const blueWaveEffect:String = "UI_songhua_blue";

        public function FlowerEffectImpl()
        {
            return;
        }// end function

        public function wave(param1:SFlowerNoticeMsg, param2:Function) : void
        {
            this._flowerMsg = param1;
            this._callBack = param2;
            this.playWaveEffect();
            FlowerEffect.instance.showEffect(param1.fromPlayer, param1.toPlayer);
            return;
        }// end function

        protected function playWaveEffect() : void
        {
            if (this._waveEffect)
            {
                this._waveEffect.dispose();
            }
            var _loc_1:* = UIEffectList.instance.getRenderListByUILayerID(UILayerIDs.ScreenID);
            var _loc_2:* = new ItemData(this._flowerMsg.itemCode);
            var _loc_3:* = _loc_2.itemInfo.type == EPropFlowerType._EPropFlowerRed ? (redWaveEffect) : (blueWaveEffect);
            this._waveEffect = EffectPlayerPool.instance.getEffectPlayer(_loc_3, Game.scene.playerLayer, _loc_1, true);
            this._waveEffect.play(PlayMode.ANIMATION_STOP_MODE);
            this._t = setTimeout(this.playComple, 5500);
            return;
        }// end function

        protected function playComple(param1 = null) : void
        {
            if (this._waveEffect)
            {
                this._waveEffect.dispose();
                this._waveEffect = null;
            }
            if (this._callBack != null)
            {
                this._callBack.call(null);
            }
            this.dispose();
            return;
        }// end function

        protected function dispose() : void
        {
            if (this._waveEffect)
            {
                this._waveEffect.dispose();
                this._waveEffect = null;
            }
            clearTimeout(this._t);
            this._t = 0;
            this._callBack = null;
            this._flowerMsg = null;
            ObjectPool.disposeObject(this);
            return;
        }// end function

    }
}
